#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
int t, n, m, l, v, cnt;
int le[N], ri[N];
struct node{
    int l, r;
}pt[N];
int a[N], b[N], c[N], p[N];

bool cmp(node a, node b){
    return a.l < b.l;
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> t;
    while (t--){
        cnt = 0;

        cin >> n >> m >> l >> v;
        for (int i = 1; i <= n; i++){
            cin >> a[i] >> b[i] >> c[i];
        }
        for (int i = 1; i <= m; i++){
            cin >> p[i];
        }

        for (int i = 1; i <= n; i++){
            int l, r, ans;
            l = 1; r = m; ans = m + 1;
            while (l <= r){
                int mid = (l + r) >> 1;
                if (p[mid] >= a[i]){
                    ans = mid;
                    r = mid - 1;
                }
                else l = mid + 1;
            }

            int pos = ans;

            l = pos; r = n; le[i] = 0;
            while (l <= r){
                int mid = (l + r) >> 1;
                int spd = b[i] * b[i] + 2 * c[i] * (p[mid] - a[i]);
                int lmt = v * v;
                if (spd > lmt){
                    le[i] = mid;
                    r = mid - 1;
                }
                else{
                    if (a[i] < 0) r = mid - 1;
                    else l = mid + 1;
                }
            }

            if (le[i]){
                cnt++;
            }

            l = pos; r = n; ri[i] = 0;
            while (l <= r){
                int mid = (l + r) >> 1;
                int spd = b[i] * b[i] + 2 * c[i] * (p[mid] - a[i]);
                int lmt = v * v;
                if (spd > lmt){
                    ri[i] = mid;
                    l = mid + 1;
                }
                else{
                    if (a[i] < 0) r = mid - 1;
                    else l = mid + 1;
                }
            }
            pt[i] = {le[i], ri[i]};
        }
        sort(pt + 1, pt + n + 1, cmp);
        int ans = 0, lef = -1, rig = -1;
        for (int i = 1; i <= n; i++){
            if (pt[i].l == 0) continue;
            if (pt[i].l > rig){
                ans++;
                lef = pt[i].l;
                rig = pt[i].r;
            }
            else{
                lef = max(lef, pt[i].l);
                rig = min(rig, pt[i].r);
            }
        }
        cout << cnt << " " <<  n - ans << "\n";
    }

    return 0;
}